<?php
/**
 * The html template file of index method of blog module of ZenTaoPHP.
 *
 * The author disclaims copyright to this source code.  In place of
 * a legal notice, here is a blessing:
 * 
 *  May you do good and not evil.
 *  May you find forgiveness for yourself and forgive others.
 *  May you share freely, never taking more than you give.
 */
?>
<?php include '../../common/view/header.html.php';?>
<div id="sidebar">
<div class="accordion open">
<a href=""  class="accordion-toggle">升级配置<i class="slider_arrow"></i></a>
<div class="accordion-body">
<ul>
<li><?php echo html::a($this->createLink($moduleName,'areaconf'), '区域配置');?></li>
<li class="active"><?php echo html::a($this->createLink($moduleName,'typeconf'), '网站类型配置');?></li>
<li><?php echo html::a($this->createLink($moduleName,'unitconf'), '单位管理');?></li>
</ul>
</div>
</div>
</div>
 <div id="main" class="alarm_mynews">
    <div class="main_title">升级配置<span class="level_divide">&gt; &gt;</span>网站类型配置</div>
    <div class="main_body">
    	<div id="report_title">
              <div class="right">
                    <span id="search_lab">关键字：</span>
                    <div id="item_search" style="float:left">
                        <input type="text" name="key_word" id="key_word" class="" value="<?php if(isset($_GET['key_word'])) echo $_GET['key_word']; ?>" style="width:120px;" placeholder="请输入关键词"/>
                        <a href="javascript:void(0);" class="search" onClick="startSearch('updateopt','typeconf','key_word')" title="查找"></a>
                    </div> 
            	</div>  
        	</div>
        <table class="table">
            <thead>
                <tr>
                    <td width="50px">ID</td>
                    <td>名称</td>
                    <td>备注</td>
                    <td width="120px;" align="center">操作</td>
                </tr>
            </thead>
            <tbody>
             <?php foreach($type_info_list as $item):?>
              <tr>
                <td><?php echo $item->type_id;?></td>
                <td><?php echo $item->type_name;?></td>
                <td><?php echo $item->type_remark;?></td>
                <td align="center">
                    <a href="javascript:void(0)" onClick="add_type(<?php echo $item->type_id;?>)">编辑</a>
                      &nbsp;&nbsp;
				    <a href="javascript:void(0)" onClick="del_type(<?php echo $item->type_id;?>)">删除</a>
                </td>
              </tr>  
              <?php endforeach;?>  
            </tbody>
        </table>
            <div>
               <div class="control-group" style="margin-top:10px; float:left">
                <label class="control-label" for=""></label>
                    <div class="controls">
                        <input type="button" class="btn btn-primary" value="添加类型" onClick="add_type()" />
                    </div>
               </div>
               
                 <div class="pages">
                <?php 
                   // echo html::a(inlink('create'), $lang->blog->add, '', "class='btn btn-primary'");
                    $pager->show('right', 'full');
               ?>
                </div>
            </div>
         </div>
    </div>
<?php include '../../common/view/footer.html.php';?>
<script src="<?php echo $jsRoot?>iDialog/jquery.iDialog.js" dialog-theme="default"></script>
<script type="text/javascript">
	//删除单位
	   function del_type(type_id){
	      $.dialog({
			width:300,
			lock:true,
			title:'提示信息',
			content:'确定要删除该类型吗？',
			btn: {                      
			  ok: {                     
				val: '确定',            
				type: 'green',  
				click: function(btn) {
				    $.post("index.php?m=updateopt&f=del_type_info",{type_id:type_id},
						function(data){
							if(data=='success'){
							   tipInfo('删除成功');
							   location.reload();
							}else{
							   tipInfo('删除失败');
							}
						});
				}
			  },
			  cancle: {         
				val: '取消'
			  }
			}
		  });
	   }
	  
      /**
		添加编辑类型
		*/
		function add_type(type_id){
			$.dialog({
				lock:true,
				width:660,
				title:'添加类型',
				btn: {                      //可以任意定义按钮个数
				  ok: {                     //按钮的key值，下次可用个btn方法从新设置
					val: '确定',            //按钮显示的文本
					id:'submitbt',
					type: 'green',         //样式可选参数green, blue, red, yellow .默认白色。
					click: function(btn) {
					  if($('#add_type_form').checkAjaxForm(1)){
						  $.post("index.php?m=updateopt&f=done_add_type",$("#add_type_form").serialize(),
							function(data){
								var opt="添加";
								if(type_id){
				   					opt="编辑";
								}
								if(data=='success'){
									tipInfo(opt+'成功');
									location.reload();
								}else{
								   tipInfo(opt+'失败');
								}
							});
					   }else{
					   		return false;
					   }
					}
				  },
				  cancle: {
					val: '取消'
				  }
				},
			 init:function(){
			    var that=this;
				 if(type_id){
				    that.$title.html('编辑类型');
				 }
				 $.post("index.php?m=updateopt&f=add_type",{type_id:type_id},
					function(data){
					    that.$content.html(data);
						that.$dialog.css('height','auto');
						/*that.$content.css('height','200');
						that.$content.css('overflow','auto');*/
						$('#add_type_form').checkForm(1,'submitbt');
				    });
			  }
			 });
	   }
</script>
